package com.lanjiu.lib.communication.event;

import com.lanjiu.pro.business.BusinessProtocolMessageStandard;

import io.netty.channel.Channel;

/**
 * @description: 与应用层交互的listener
 * @author: Panwei
 * @date: 2019/10/28 14:30
 */
public interface OnEventListener {

    BusinessProtocolMessageStandard.UnifiedEntranceMessage beforeDispatchMsg(Channel channel, BusinessProtocolMessageStandard.UnifiedEntranceMessage msg);

    /**
     * 分发消息到应用层
     *
     * @param msg
     */
    void dispatchMsg(BusinessProtocolMessageStandard.UnifiedEntranceMessage msg);

    /**
     * 从应用层获取网络是否可用
     *
     * @return
     */
    boolean isNetworkAvailable();

    /**
     * 获取重连间隔时长
     *
     * @return
     */
    default int getReconnectInterval() {
        return 0;
    }

    /**
     * 获取请求超时时长
     *
     * @return
     */
    default int getRequestTimeoutMillis() {
        return 0;
    }

    /**
     * 获取连接超时时长
     *
     * @return
     */
    default int getConnectTimeout() {
        return 0;
    }


    /**
     * 获取应用层消息发送超时重发次数
     *
     * @return
     */
    default int getResendCount() {
        return 0;
    }

    /**
     * 获取应用层消息发送超时重发间隔
     *
     * @return
     */
    default int getResendInterval() {
        return 0;
    }


    void close();
}
